function drag(box) {
    var oDiv = document.getElementById(box);
    var disX = 0,
        disY = 0;
        // 鼠标按下
    oDiv.addEventListener('mousedown', function (e) {
        //阻止默认行为
        e.preventDefault();
        disX = e.clientX - oDiv.offsetLeft;
        disY = e.clientY - oDiv.offsetTop;
        // console.log('按下：' + (disX + "-" + disY));

         // 鼠标按下且移动
        document.onmousemove = function (e) {
            var l = e.clientX - disX;
            var t = e.clientY - disY;

            var r = document.documentElement.clientWidth - oDiv.offsetWidth;
            var b = document.documentElement.clientHeight - oDiv.offsetHeight;

            if (l < 0) l = 0;
            if (l > r) l = r;
            if (t < 0) t = 0;
            if (t > b) t = b;

            oDiv.style.left = l + 'px';
            oDiv.style.top = t + 'px';
            // console.log('移动：' + (e.clientX - disX) + "-" + (e.clientY - disY));
            //alert(pos.y-disY);
        };
        // 鼠标松开且移动
        document.onmouseup = function () {
            document.onmousemove = null;
            document.onmouseup = null;
        };

        return false;
    });


}
drag('jp_container_N');